"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateUser = exports.delUser = exports.getUserList = exports.readRegisterData = exports.readLoiginData = void 0;
const sqlTool_1 = require("../tool/sqlTool");
// 读取登录数据
function readLoiginData(user) {
    return __awaiter(this, void 0, void 0, function* () {
        return (0, sqlTool_1.dosql)(`select * from users where email=? and password=? `, [
            user.email,
            user.password,
        ]);
    });
}
exports.readLoiginData = readLoiginData;
// 注册用户数据
function readRegisterData(user) {
    return __awaiter(this, void 0, void 0, function* () {
        return (0, sqlTool_1.dosql)(`insert into users (email,password,nick,introduction,uid) values (?,?,?,?,uuid()) `, [user.email, user.password, user.nick, user.introduction]);
    });
}
exports.readRegisterData = readRegisterData;
// 获取用户数据
function getUserList(page) {
    return __awaiter(this, void 0, void 0, function* () {
        return (0, sqlTool_1.dosql)(`select * from users order by id desc limit ${(page - 1) * 10},10;`, []);
    });
}
exports.getUserList = getUserList;
//删除用户
function delUser(id) {
    return __awaiter(this, void 0, void 0, function* () {
        return (0, sqlTool_1.dosql)(`delete from users where id=${id}`, []);
    });
}
exports.delUser = delUser;
// 更新用户
function updateUser(user) {
    return __awaiter(this, void 0, void 0, function* () {
        return (0, sqlTool_1.dosql)(`update users set email=?,password=?,nick=?,introduction=? where id=?`, [user.email, user.password, user.nick, user.introduction, user.id]);
    });
}
exports.updateUser = updateUser;
